<template>
	<div class="">
		<header class="top_bar">
			<a onclick="window.history.go(-1)" class="icon_back"></a>
			<h3 class="cartname">修改密码</h3>
			<a href="#" class="icon_menu"></a>
		</header>
		<section class="padding_top45">
			<div class="line_height40 border_bot_999 background_fff padding_lf10_rg10">
				<label for="">原密码：</label>
				<input v-model="oldPassword" type="password" placeholder="请输入原密码"/>
			</div>
			<div class="line_height40 border_bot_999 background_fff padding_lf10_rg10">
				<label for="">新密码：</label>
				<input v-model="newPassword" type="password" placeholder="请输入新密码"/>
			</div>
			<div class="line_height40 border_bot_999 background_fff padding_lf10_rg10">
				<label for="">新密码：</label>
				<input v-model="againPassword" type="password" placeholder="请再次输入新密码"/>
			</div>
		</section>
		<div @click="ModifyPwd()" class="btn_bot">
			修改
		</div>
	</div>
</template>
<script>
	import { Toast } from 'mint-ui';
	export default {
		data() {
			return {
				oldPassword: '',
				newPassword: '',
				againPassword: '',
			}
		},
		mounted() {},
		methods: {
			ModifyPwd() {
				let _this = this;
				if(_this.againPassword!=_this.newPassword){
					Toast('两次输入的密码不一样！')
					return false;
				}
				_this.$http.put('client/Password', {
					oldPass: _this.oldPassword,
					newPass: _this.newPassword,
				}, localStorage.Authorization, res => {
					console.log('修改密码res', res)
					if(res.code === 200) {
						Toast(res.data)
						_this.$router.push({path: '/login'})
					}else if(res.code === 101) {
						localStorage.fromPath = _this.$route.fullPath
						_this.$router.push({
							path: '/login'
						})
					}else{
						Toast(res.error)
					}
				})
			},
		}
	}
</script>
<style scoped="scoped">
	.btn_bot {
		position: fixed!important;
	}
	
	.footer {
		display: none;
	}
</style>